package com.example.mrzhou.lvmm.view.adapter.destination;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mrzhou.lvmm.R;
import com.example.mrzhou.lvmm.commom.utils.ImageLoader;
import com.example.mrzhou.lvmm.entity.destination.Destination;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Mr.zhou on 2016/10/29.
 */

public class DesSampleAdapter extends RecyclerView.Adapter<DesSampleAdapter.DesViewHolder> {

    private List<Destination.DatasBean.InfosBean> data;
    private Context context;

    public DesSampleAdapter(List<Destination.DatasBean.InfosBean> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public DesViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new DesViewHolder(LayoutInflater.from(context).inflate(R.layout.item_list_des_sample, parent, false));
    }

    @Override
    public void onBindViewHolder(DesViewHolder holder, int position) {
        ImageLoader.getInstance().displayImage(data.get(position).getLargeImage(), context, holder.ivDesImg, R.drawable.hot_loading, R.drawable.hot_loading);
        holder.tvDesKeyword.setText(data.get(position).getKeyword());
        holder.tvDesTitle.setText(data.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return data != null ? data.size() : 0;
    }

    public class DesViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.iv_des_img)
        ImageView ivDesImg;
        @BindView(R.id.tv_des_keyword)
        TextView tvDesKeyword;
        @BindView(R.id.tv_des_title)
        TextView tvDesTitle;

        public DesViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
